package com.atguigu.tingshu.album.api;


import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.cache.GuiguCache;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
public class BaseCategoryApiController {
    @Autowired
    private BaseCategoryService baseCategoryService;

//    @GuiguCache(prefix = "getCategoryInfo")
    @GetMapping("/getBaseCategoryList")
    public Result getCategoryInfo(){
        return Result.ok(baseCategoryService.getCategoryInfo());
    }

//    @GuiguCache(prefix = "findAttribute")
    @GetMapping("/findAttribute/{categoryId}")
    public Result<List<BaseAttribute>> findAttribute(@PathVariable(value = "categoryId") Long id){
        return Result.ok(baseCategoryService.findAttribute(id));
    }

    /**
     * 获取前七名三级分类
     * @param category1Id
     * @return
     */
//    @GuiguCache(prefix = "findTopBaseCategory3")
    @GetMapping("/findTopBaseCategory3/{category1Id}")
    public Result findTopBaseCategory3(@PathVariable(value = "category1Id")Long category1Id){
        return Result.ok(baseCategoryService.findTopBaseCategory3(category1Id));
    }
}

